/**
 * Created with JetBrains WebStorm.
 * User: Administrator
 * Date: 14-5-27
 * Time: 上午11:27
 * To change this template use File | Settings | File Templates.
 */
define(function(require,exports,module){
    var VERSION = "1.0.0",
        jquery = $ = require("jquery-1.8.2.min.js");

    var ch = [

    ];

    function scalculator(element){
        this.elem = $(element);
        this.bindEvent();
    }
    scalculator.prototype = {
        bindEvent:function(){
            var that = this;
            this.elem.find("#interCalc").bind('click',function(){
                that.valid();
            })
        },
        valid:function(){
            this.loanSum = this.elem.find("#deposit").val();
            this.yearRate = this.elem.find("#wage").val();
            this.scale = this.elem.find("#scale").val();
            this.time = this.elem.find("#time").val()

            this.calculate();
        },
        calculate:function(){
            var cmoney,sumMoney,month ;
            cmoney = this.loanSum;
            month= this.time * 12 ;

            sumMoney = parseFloat(cmoney) + parseFloat(month*this.yearRate*this.scale/100)

            console.log((sumMoney - cmoney)/cmoney)
            console.log(sumMoney)
        }
    };
    return scalculator;
})